package com.szqhyxj.youxiangju.biz.documentphoto;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.szqhyxj.youxiangju.R;
import com.szqhyxj.youxiangju.sys.components.LoadImageUtils;
import com.szqhyxj.youxiangju.sys.components.NavigationBar;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by leung on 2018/10/30.
 */

public class DocumentPhotoActivity extends Activity implements DocumentPhotoContract.View, NavigationBar.NavigationBarListener {
    @BindView(R.id.idCardFacepic)
    ImageView idCardFacepic;
    @BindView(R.id.idCardBackpic)
    ImageView idCardBackpic;

    DocumentPhotoPresenter presenter;
    @BindView(R.id.bankCardPic)
    ImageView bankCardPic;
    @BindView(R.id.handIdCard)
    ImageView handIdCard;
    @BindView(R.id.navigationBar)
    NavigationBar navigationBar;
    @BindView(R.id.handIdCardtitile)
    TextView handIdCardtitile;


    public static void start(Activity activity) {
        Intent intent = new Intent();
        intent.setClass(activity, DocumentPhotoActivity.class);
        activity.startActivity(intent);

    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_document_photo);
        ButterKnife.bind(this);
        presenter = new DocumentPhotoPresenter(this);
        presenter.picUrl();
        navigationBar.setNavigationBarListener(this);

    }

    @Override
    public void showIcCardFace(String s) {
        if (s == null || s.equals("")) {
            idCardFacepic.setImageResource(R.mipmap.shengfenzheng_08);
        } else {
            LoadImageUtils.loadImageRotation(idCardFacepic, s, 270);
        }

    }

    @Override
    public void showIcCardBack(String s) {
        if (s == null || s.equals("")) {
            idCardBackpic.setImageResource(R.mipmap.shengfenzheng_09);
        } else {
            LoadImageUtils.loadImageRotation(idCardBackpic, s, 270);
        }

    }

    @Override
    public void showCreditCard(String s) {
        if (s == null || s.equals("")) {
            bankCardPic.setImageResource(R.mipmap.shengfenzheng_08);
        } else {
            LoadImageUtils.loadImageRotation(bankCardPic, s, 270);
        }

    }

    @Override
    public void showHandheldIdCard(String s) {
        if (s == null || s.equals("")) {
            handIdCard.setImageResource(R.mipmap.shengfenzheng_09);
        } else {
            handIdCardtitile.setText("手持身份证 ");
            LoadImageUtils.loadImageRotation(handIdCard, s, 270);

        }

    }

    @Override
    public void showToast(String s) {
        Toast.makeText(this, s, Toast.LENGTH_LONG).show();
    }

    @Override
    public void navigationLeft() {
        finish();
    }

    @Override
    public void navigationRight() {

    }
}
